package com.woniu.service.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.woniu.entity.Comment;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CommentVo {
    private Long id;
    private Long parentId;
    private Integer display;

    private String testCode;

    /**
     * 被评论者code
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commentedCode;

    /**
     * 评论code
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commentCode;

    private Date commentUpdateTime;

    private Date commentCreateTime;

    /**
     * 点赞量
     */
    private Integer likeNumber;

    /**
     * 评论内容
     */
    private String commentDetail;
    /**
     * 用户姓名
     */
    private String username;
    /**
     * 用户头像url地址
     */
    private String profilePhoto;
    private List<CommentVo> children;
    private Integer isLike;
    public CommentVo(Comment comment){
        this.display=comment.getDisplay();
        this.id=comment.getId();
        this.parentId=comment.getParentId();
        this.testCode = comment.getTestCode().toString();
        this.commentedCode = comment.getCommentedCode();
        this.commentCode = comment.getCommentCode();
        this.commentUpdateTime = comment.getCommentUpdateTime();
        this.commentCreateTime = comment.getCommentCreateTime();
        this.likeNumber = comment.getLikeNumber();
        this.commentDetail = comment.getCommentDetail();
        this.username = comment.getUsername();
        this.profilePhoto = comment.getProfilePhoto();
        this.children = new ArrayList<>();
        this.isLike=0;
    }
}
